<script setup lang="ts">
import DoctorCard from './DoctorCard.vue'
import { onMounted,ref } from 'vue'
//引入@vueuse/core 应用，自动适配
import {useWindowSize }  from '@vueuse/core'
import {getConcernDoctorListAPI} from '@/services/consult'
import { DoctorListType } from '@/types/consult'


const { width: dWidth } = useWindowSize()
//响应式数据保存关注医生列表
const list = ref<DoctorListType>()
//获取关注医生列表数据
const getConcernDoctorList = async() =>{
    const res = await getConcernDoctorListAPI({current:1,pageSize:5})
    // console.log('关注',res);   
    list.value = res.data.rows
}

onMounted(()=>{
    getConcernDoctorList()
})

</script>

<template>
  <div class="follow-doctor">
    <div className="head">
      <p>推荐关注</p>
      <a href="javascript:;"> 查看更多<i class="van-icon van-icon-arrow" /></a>
    </div>
    <div class="body">
        <!-- :show-indicators="false" 去除指示器 -->
        <!-- :loop="false" 设置循环播放 -->
        <!-- swipe组件 -->
        <van-swipe :width="(150/375) * dWidth " :show-indicators="false" :loop="false">
        <van-swipe-item v-for="item in list" :key="item.id">
          <doctor-card :item="item"/>
        </van-swipe-item>
      </van-swipe>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.follow-doctor {
  background-color: var(--cp-bg);
  height: 250px;
  .head {
    display: flex;
    justify-content: space-between;
    height: 45px;
    align-items: center;
    padding: 0 15px;
    font-size: 13px;
    > a {
      color: var(--cp-tip);
    }
  }
  .body {
    width: 100%;
    overflow: hidden;
  }
}
</style>